package com.milhouz.wormdroid.gl.model;

import simpull.Vector2f;
import android.util.Log;

import com.milhouz.wormdroid.data.model.WeaponData;
import com.milhouz.wormdroid.util.StaticValues;

/**
 * Wormdroid Weapon Sprite
 */
public class WeaponGLSprite extends GLSprite {
	
	private final static int DEFAULT_MASS = 1;
	
	public WeaponData weaponData;
	
	public boolean isShowed = false;
	public boolean isLaunched = false;
	
	public WeaponGLSprite(int id, int x, int y, WeaponData weaponData) {
		super(id, x, y, weaponData.getWidth(), weaponData.getHeight(), false, DEFAULT_MASS, 0, 0, weaponData.getImgBullet());
		this.weaponData = weaponData;
	}
	
	public void launch(int targetX, int targetY) {
		Log.d(StaticValues.LOG_TAG,"tx"+targetX/10+"-ty"+targetY/10);
		setVelocity(new Vector2f(targetX/2,targetY/2));
		isLaunched = true;
	}
	
	public void centerTargetToCoordonates(int centerX, int centerY) {
		if (!isLaunched) {
			this.setX(centerX);
			this.setY(centerY);
		}
	}

}
